package com.metacube.questionbank.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
import com.metacube.questionbank.model.Answer;

/*
 * @author Team Neeraj Jain
 * */
public class QuestionAnswerExtractor implements ResultSetExtractor<Answer> {
	/*
	 * @param resultset This method sets the data from the resultSet to the
	 * object of Answer class
	 * 
	 * @return object of answer class.
	 */
	public Answer extractData(ResultSet resultSet) throws SQLException,
			DataAccessException {
		Answer answer = new Answer();
		answer.setAnsId(resultSet.getInt(1));
		answer.setAnswerDesc(resultSet.getString(2));
		answer.setUserId(resultSet.getInt(3));
		answer.setAnswerDate(resultSet.getTimestamp(5));
		answer.setQuestionId(resultSet.getInt(4));
		return answer;
	}
}
